using System;

namespace ErrorCode
{
    /// <summary>
    /// API异常类
    /// </summary>
    public class ApiException : Exception
    {
        /// <summary>
        /// 错误码
        /// </summary>
        public ResultCode Code { get; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="code">错误码</param>
        /// <param name="message">错误消息</param>
        public ApiException(ResultCode code, string message) : base(message)
        {
            Code = code;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="code">错误码</param>
        /// <param name="message">错误消息</param>
        /// <param name="innerException">内部异常</param>
        public ApiException(ResultCode code, string message, Exception innerException) : base(message, innerException)
        {
            Code = code;
        }
    }
} 